package com.jeff.tianti.cms.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jeff.tianti.common.entity.BaseEntity;
import com.jeff.tianti.common.util.DateUtils;

import javax.persistence.*;
import java.util.Date;

import static javax.persistence.CascadeType.*;

@Entity
@Table(name = "course_counsel")//课程咨询表
@JsonIgnoreProperties(value={"course","hibernateLazyInitializer","handler","fieldHandler"})
public class CourseCounsel extends BaseEntity {
    private static final long serialVersionUID = -6703106641656854621L;
    @Column(name = "uid")
    private String uid;//用户id
    private Course course;//课程表
    private String courseId;//课程id
    private String courseName;//课程名称
    private String linkName;//联系人姓名
    private String linkNum;//联系人号码
    private String text;//咨询描述
    private String reply;//回复
    private Date replyDate;//回复时间
    private String state;//0->咨询中 1->已完成
    private String dateString;
    private String replyDateString;
    @Transient
    public String getDateString() {
        if (createDate != null) {
            return DateUtils.dateToString(createDate,"yyyy-MM-dd");
        }
        return "";
    }

    public void setDateString(String dateString) {
        this.dateString = dateString;
    }

    @Transient
    public String getReplyDateString() {
        if (replyDate != null) {
            return DateUtils.dateToString(replyDate,"yyyy-MM-dd");
        }
        return "";
    }

    public void setReplyDateString(String replyDateString) {
        this.replyDateString = replyDateString;
    }

    @ManyToOne(fetch=FetchType.LAZY,optional = false)
    @JoinColumn(name = "course_id",updatable = false,insertable = false)
    public Course getCourse() {
        return course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }

    @Column(name = "course_id")
    public String getCourseId() {
        return courseId;
    }

    public void setCourseId(String courseId) {
        this.courseId = courseId;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }
    @Transient
    public String getCourseName() {
        if (course != null) {
            return course.getName() == null ? "" : course.getName();
        }
        return "";
    }

    public void setCourseName(String courseName) {
        this.courseName = courseName;
    }
    @Column(name = "reply")
    public String getReply() {
        return reply;
    }

    public void setReply(String reply) {
        this.reply = reply;
    }
    @Column(name = "link_name")
    public String getLinkName() {
        return linkName;
    }

    public void setLinkName(String linkName) {
        this.linkName = linkName;
    }
    @Column(name = "link_num")

    public String getLinkNum() {
        return linkNum;
    }

    public void setLinkNum(String linkNum) {
        this.linkNum = linkNum;
    }
    @Column(name = "text")

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
    @Column(name = "reply_date")

    public Date getReplyDate() {
        return replyDate;
    }

    public void setReplyDate(Date replyDate) {
        this.replyDate = replyDate;
    }
    @Column(name = "state")
    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }
}
